import JsCookie from "js-cookie";
// const JsCookie = require('js-cookie') // 以模块方式导入
/**
 *
 * @param {String} name 名称
 * @param {*} value 值
 * @param {Object} cookieSetting 配置
 */
export function setCookie(name: string, value: any, cookieSetting: object) {
  const currentCookieSetting = {
    expires: 1, // 1天
  };
  Object.assign(currentCookieSetting, cookieSetting);

  JsCookie.set(`${name}`, value, currentCookieSetting);
}
/**
 *
 * @param {String} name
 */
export function getCookie(name: string) {
  return JsCookie.get(`${name}`);
}
/**
 * 获取全部cookie
 */
export function getCookieAll() {
  return JsCookie.get();
}
/**
 *
 * @param {String} name 名称
 */
export function removeCookie(name: string) {
  return JsCookie.remove(`${name}`);
}

// 设置原始cooike
export function setOriginalCookie(
  name: string,
  value: any,
  cookieSetting: object
) {
  const currentCookieSetting = {
    expires: 1,
  };
  Object.assign(currentCookieSetting, cookieSetting);

  JsCookie.set(`${name}`, value, currentCookieSetting);
}
